package com.woniuxy.vouchers.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.commons.request.ResponseResult;
import com.woniuxy.vouchers.entity.Vouchers;
import com.woniuxy.vouchers.service.VouchersService;
import com.woniuxy.vouchers.vo.GetVouchersVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/vouchers")
public class VouchersController {

    @Resource
    private VouchersService VouchersService;
    @GetMapping("/findAll")
    public ResponseResult<PageInfo<Vouchers>> findAll(Integer currentPage, Integer pageSize, String name){
        return new ResponseResult<>(ResponseResult.OK,VouchersService.findAll(currentPage,pageSize,name));
    }

    @PostMapping("/getVouchers")
    public ResponseResult<Boolean> getVouchers(@RequestBody GetVouchersVo getVouchersVo){
       return new ResponseResult<>(ResponseResult.OK,VouchersService.getVouchers(getVouchersVo));
    }

    //增
    @PostMapping("/addVouchers")
    public ResponseResult<Boolean> addVouchers(@RequestBody Vouchers vouchers){
        return new ResponseResult<>(ResponseResult.OK,VouchersService.addVouchers(vouchers));
    }

    //编辑
    @PutMapping("/updateVouchers")
    public ResponseResult<Boolean> updateVouchers(@RequestBody Vouchers vouchers){
        return new ResponseResult<>(ResponseResult.OK,VouchersService.updateVouchers(vouchers));
    }

}
